package sdk

import (
	"gddgame.cc/galaxy/server/composer"
	"gddgame.cc/galaxy/utils/def"
)

type AppClient struct {
	def.Context
	def.StoreFactory
	AppPlatform
	appKey    string
	appSecret string
	Version   string
}

func NewAppClient(context def.Context, factory def.StoreFactory, appKey string, appSecret string) (*AppClient, error) {
	client := &AppClient{
		Context:      context,
		StoreFactory: factory,
		appKey:       appKey,
		appSecret:    appSecret,
	}
	platform, err := newAppPlatform(context, client)
	if err != nil {
		return nil, err
	}
	client.AppPlatform = platform
	return client, nil
}

type ServiceClient struct {
	composer.Builder
	ServicePlatform
}

func NewServerClient(builder composer.Builder) (*ServiceClient, error) {
	client := &ServiceClient{
		Builder: builder,
	}
	platform, err := newServerPlatform(client)
	if err != nil {
		return nil, err
	}
	client.ServicePlatform = platform
	return client, nil
}
